package me.tuyou.rmi.httpinvoker.client;

import me.tuyou.rmi.httpinvoker.service.MyService;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean;

/**
 * @Description
 * @Author tuyou_cd
 * @Date 2020/6/19 19:06
 */
@Configuration
public class HttpInvokerClientApp {

    @Bean
    public HttpInvokerProxyFactoryBean httpInvokerProxyFactoryBean() {
        HttpInvokerProxyFactoryBean factoryBean = new HttpInvokerProxyFactoryBean();
        factoryBean.setServiceUrl("http://localhost:8080/myService");
        factoryBean.setServiceInterface(MyService.class);
        return factoryBean;
    }

    public static void main(String[] args) {
        AnnotationConfigApplicationContext context =
                new AnnotationConfigApplicationContext("me.tuyou.rmi.httpinvoker.client");

        MyService bean = context.getBean(MyService.class);
        System.out.println(bean.add(1, 4));
    }
}
